home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 2126 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.0 KB

  1. Path: fontina.cs.wisc.edu!flisakow
  2. From: flisakow@fontina.cs.wisc.edu (Shaun Flisakowski)
  3. Newsgroups: comp.lang.c,comp.programming
  4. Subject: Re: Trying to store a triangular matrix
  5. Followup-To: comp.programming
  6. Date: 19 Jan 1996 08:38:14 GMT
  7. Organization: U of Wisconsin CS Dept
  8. Message-ID: <4dnl9m$532@spool.cs.wisc.edu>
  9. References: <sksen.821949883@merle>
  10. NNTP-Posting-Host: fontina.cs.wisc.edu
  11.  
  12. In article <sksen.821949883@merle>, Subhro Sen <sen@nwu.edu> wrote:
  13. >
  14. >I am trying to store a 2D lower triangular N x N matrix in
  15. >a 1D array...in other words i want A[i][j] to
  16. >map to some index m. What's the formula!?!?!
  17. >It's a lower triangular matrix, (A[i][j] = 0 for j > i)
  18. >i.e.:
  19. >
  20. >
  21. >1  0   0   0 
  22. >2  1   0   0
  23. >5  3   2   0
  24. >9  3   4   1
  25. >
  26.  
  27.     addr = 2^i + j - 1
  28.  
  29.     Where ^ is used to indicate power-of, and not C's xor.
  30.  
  31.     Followups set to comp.programming, as this has nothing to do with C.
  32.  
  33. -- 
  34.     Shaun        flisakow@cs.wisc.edu
  35.  
  36.    "In your heart you know its flat."
  37.                            -Flat Earth Society
  38.